<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <p></p>
  <button>按钮</button>
  <script>
    localStorage.setItem('key', 123)
    const p = document.querySelector('p')
    const btn = document.querySelector('button')
    p.innerHTML = localStorage.getItem('key')
    btn.onclick = () => {
      localStorage.setItem('key', 456)
      p.innerHTML = localStorage.getItem('key')
    }
  </script>
</body>
</html>